Network User Information - Obtain the login name of the person using the system.
Written by:
Chad Hegerty
CompuServe: 71212,1045
MSN: HegertyC
Please see the bottom of this document for version history.
This program is donationware. If you find the program useful, and use
it in your environment, consider sending $10.00 to:
Chad Hegerty
PO Box 844
Worthington, OH 43085
I'm not trying to make a lot of money off this code, but I have spent
considerable time in building and testing these code modules.
This ZIP file contains four (4) separate areas.
Three areas are VBA code and the fourth area is an OLE Server area. The VBA code is broken out into the following (the programs listed may not be the only programs able to use these modules):
16-Bit - Used for 16 bit coding environments (Access 2, VB 3 & 4 16-bit, Excel 5, etc.)
32-Bit - Used for 32 bit coding environments (VB 4 32-bit, Access 7, Excel 7, etc.)
Conditional - Used in environments where conditional compilation is possible (VB 4.0)
Below is the declaration and function call needed to obtain the logon name.
dim strUserID as string
strUserID = NetworkUserID()
If the user is not signed in or the ID cannot be obtained, then the
string "UnknownUser" is returned.
The OLE Server area contains more detailed information about the computer that the user is signed into. These OLE Servers can return the following information:
Name - Name of the computer
User - User of the computer (who is logged in)
Windows - Directory where Windows is installed
WinSystem - Directory where Windows SYSTEM is installed
The OLE servers are compiled into the following versions:
COMPINFO.EXE - 16-bit "out-of-process" OLE server
COMPINFO32.EXE - 32-bit "out-of-process" OLE server
COMPINFO32.DLL - 32-bit "in-process" OLE server
To register the EXE servers you need to run the EXE once, this will
register the OLE object. You may need to include the OLE 2.0 files
if the users machines do not have OLE 2.0 already installed.
Below is the declaration and function call needed for the
computer information (for VB and Access, other programs may differ in
their syntax for calling OLE objects.
dim obj as object
set obj = CreateObject("ComputerInfo.Application")
debug.print obj.Name
debug.print obj.User
debug.print obj.Windows
debug.print obj.WinSystem
If you are using the 16-bit COMPINFO.EXE, then the Name property will
return "Unknown". If I get enough response, I will code the computer name
for the 16-bit OLE server.
Note: If you have other items about the computer that you think would
be helpful, drop me an e-mail. I will try to include it in an
upcoming release.
Note: If the user might be running on Windows 95, or Windows NT, with the 16-bit
versions, then the CALL32.DLL file needs to be included. This file needs to be
installed in the users SYSTEM directory where they have Windows installed.
The CALL32.DLL module, along with its text file, should be included with this file.
Please feel free to redistribute these files in their entirety.
No guarantees are made as to its suitability or usefulness.
Thank you
Chad Hegerty
Internet: 71212.1045@compueserve.com - or -
HegertyC@MSN.COM
CompuServe: 71212,1045
MSN: HegertyC
Version History:
12/07 Orignial
12/15 Corrected WNetGetUser return types from 16 bit code.
Corrected string trimming to ignore Null character.
12/18 Corrected Left$ parsing for WFW and Windows 3.x clients.